package com.github.maojx0630.easy.translate.select.impl;

import com.github.maojx0630.easy.translate.translate.impl.dict.DictConfig;
import com.github.maojx0630.easy.translate.conf.TranslateConfig;
import com.github.maojx0630.easy.translate.select.DictSelect;

/**
 * @author 毛家兴
 * @since 2024-02-06 09:41
 */
public class DictSelectService implements DictSelect {

  private final SelectMapper mapper;

  private final DictConfig config;

  public DictSelectService(SelectMapper mapper, TranslateConfig config) {
    this.mapper = mapper;
    this.config = config.getDictConfig();
    this.config.check();
  }

  @Override
  public String selectDict(String typeValue, String inValue, String remark) {
    return mapper.selectDict(
        typeValue,
        inValue,
        config.getLabel(),
        config.getTable(),
        config.getType(),
        config.getValue());
  }
}
